﻿using Growatt.Component.Frm;
using Growatt.WaveData.DataSetResolve;
using LEDVANCE.Oscilloscope.VirtualOscilloscope.DataGridViewHelper;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using Vosc.VirtualOscilloscope;


namespace Growatt.WaveData.VirtualOscilloscope
{
    public partial class UC_BtnAddDelControl : UserControl
    {
        private readonly UC_ParameterSetting cuurentSelectItem;
        UIComboDataGridView uIListBox = null;

        /// <summary>
        /// 删除回调函数
        /// </summary>
        Action<ModelSaveString> ActionDelData = null;

        public UC_BtnAddDelControl(UC_ParameterSetting cuurentSelectItem,UIComboDataGridView uIlb, BindingList<ModelSaveString> modelSaveStrings, 
            List<ModelSaveString> modelSave, Action<ModelSaveString> action)
        {
            InitializeComponent();
            this.cuurentSelectItem = cuurentSelectItem;
            this.uIListBox = uIlb;
            ActionDelData = action;
        }
        /// <summary>
        /// 是否包含中文
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static bool hasChinese(string source)
        {
            return Regex.IsMatch(source, @"[\u4e00-\u9fa5]+", RegexOptions.IgnoreCase);
        }
        private void addBtn_Click(object sender, EventArgs e)
        {

            FrmFindAddress frmFindAddress = new FrmFindAddress(this.cuurentSelectItem.cuurentSelectItem, (o) =>
            {
                AddIntemUIControl((o.Name, o.Type, o.Scale, o.Address,o.SignalOffset));
            });
            frmFindAddress.ShowDialog();
        }
        public static bool isEmty = true;
      

        public Action<(string, string, string, string,string)> AddAction = null;
        public void AddIntemUIControl((string, string, string, string,string) name)
        {
            AddAction?.Invoke(name); //变更一下前台数据

        }

     

    }
}
